<?php
namespace App\Http\Controllers\Home;

use App\Models\Announce;
use App\Models\AnnounceAg;
use App\Models\Feedback;

Class MsgController extends BaseController{

    public function __construct(Announce $announce, AnnounceAg $announceAg, Feedback $feedback){
        parent::__construct();
        $this->announce = $announce;
        $this->announceAg = $announceAg;
        $this->feedback = $feedback;
    }

    public function getMsg(){
        $agentAnnounce = $this->announce->getAgentAnnounceList();
        $announce = $this->announceAg->getAgentAnnounceList();
        $rows = array_merge($agentAnnounce,$announce);
        return view('home.msg',compact('rows'));
    }

    public function getMsgDetai($id,$type)
    {
        if ($type == 1) {
            $data = $this->announce->getAgentAnnounceInfo($id);
        } else {
            $data = $this->announceAg->getAgentAnnounceInfo($id);
        }
        return view('home.msg_detail',compact('data'));
    }

    public function getFeedBack(){
        $rows = $this->feedback->getAgentFeedbackList();
        return view('home.feedback',compact('rows'));
    }

    public function postFeedBack(){
        $res = $this->feedback->addFeedback(request());
        return redirect()->back()->with('message', $res);
    }

}